"""
异常模块
"""

from typing import (
    Dict,
    Optional,
)

from fastapi import HTTPException

import utils.enum_utils as enum


class BusinessException(HTTPException):
    """
    业务异常

    响应状态码为 400
    """

    def __init__(
        self,
        detail: Optional[str] = None,
        headers: Optional[Dict[str, str]] = None,
    ) -> None:
        """
        异常初始化

        Args:
            detail (Optional[str]): 异常详情
            headers (Optional[Dict[str, str]]): 异常头部
        """

        super().__init__(
            status_code=enum.HTTPStatusCode.HTTP_400_BAD_REQUEST.value,
            detail=detail,
            headers=headers,
        )
